<template>
<div class="user-settings views-container">
  <div class="wlm-form">
    <div class="wlm-form-header">注册设置</div>
    <div class="wlm-form-content">
      <el-form :ref="formFormatData.key" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="120px" class="retail-form" label-position="right">
        <el-form-item label="开放注册">
          <el-radio-group v-model="formFormatData.formData.openregist">
            <el-radio label="1">开放</el-radio>
            <el-radio label="0">关闭</el-radio>
          </el-radio-group>
        </el-form-item>
        <!-- <el-form-item label="注册审核">
          <el-radio-group v-model="formFormatData.formData.registaudit">
            <el-radio label="1">打开</el-radio>
            <el-radio label="0">关闭</el-radio>
          </el-radio-group>
          <div class="form-help">新用户注册时需要审核</div>
        </el-form-item> -->
        <section v-if="formFormatData.formData.openregist==='1'">
          <el-form-item label="注册协议">
            <el-radio-group v-model="formFormatData.formData.registagreement">
              <el-radio label="1">打开</el-radio>
              <el-radio label="0">关闭</el-radio>
            </el-radio-group>
            <div class="form-help">注册用户时候，是否需要显示注册协议</div>
          </el-form-item>
          <section v-if="formFormatData.formData.registagreement==='1'">

            <el-form-item label="协议标题" prop="title">
              <el-input v-model="formFormatData.formData.title">
              </el-input>
            </el-form-item>
            <el-form-item label="协议内容" prop="content">
              <el-input type="textarea" :autosize="{ minRows: 4}" maxlength="50" v-model="formFormatData.formData.content">
              </el-input>
              <div class="form-help">输入不超过50字的内容</div>
            </el-form-item>
          </section>
        </section>
      </el-form>
    </div>
  </div>
  <div class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
    <el-button size="small" @click="formFormatSubmit" type="primary">保存</el-button>
  </div>
</div>
</template>

<script>
import {
  userSet,
  userSetOld
} from '@/api/user'
// import { regPhone } from '@/utils/regular'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  name: 'UserSettings',
  components: {

  },
  directives: {

  },
  data() {
    return {
      formFormatData: {
        key: 'userForm',
        api: {
          editForm: {
            api: userSetOld,
            params: {
              key: 'memeberSet',
              always: true
            }
          },
          submitForm: userSet
        },
        formData: {
          openregist: '1',
          registaudit: '1',
          registagreement: '1',
          title: '',
          content: '',
          key: 'memeberSet'
        },
        rules: {
          title: [{
            required: true,
            message: '请输入协议标题',
            trigger: 'blur'
          }],
          content: [{
            required: true,
            message: '请输入协议内容',
            trigger: 'blur'
          }]
        }
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.user-settings-user {}
</style>
